﻿<Framework:BasePage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Framework="clr-namespace:JustinAngel.UnitedNationsNews.Framework" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:Unsupported="clr-namespace:Microsoft.Unsupported" x:Class="JustinAngel.UnitedNationsNews.Pages.ArticleList.ArticleListPage"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="Black"
    ViewModel="{Binding ArticleListViewModel, Source={StaticResource ViewModelLocator}}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" d:DataContext="{d:DesignData /SampleData/ArticleListViewModelSampleData.xaml}">
    <Framework:BasePage.Resources>

    </Framework:BasePage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" >
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="LoadingStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1.3" To="NotIsLoading"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="IsLoading"/>
                <VisualState x:Name="NotIsLoading">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="loadingProgressBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>False</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loadingText" d:IsOptimized="True"/>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="loadingProgressBar" d:IsOptimized="True"/>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loadingText">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="loadingProgressBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.Background>
            <ImageBrush Stretch="UniformToFill" ImageSource="/UNNewsSinglePageBackground.jpg"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="United Nations News" Style="{StaticResource PhoneTextNormalStyle}" Foreground="Black">
                    <toolkit:ContextMenuService.ContextMenu>
                        <toolkit:ContextMenu IsZoomEnabled="False" Background="White" BorderBrush="Black" Foreground="Black">
                            <toolkit:MenuItem Command="{Binding SendEmailToDeveloper}" Unsupported:TiltEffect.IsTiltEnabled="True">
                                <toolkit:MenuItem.Header>
                                    <TextBlock TextWrapping="Wrap" Text="Email J@JustinAngel.net with feedback on &quot;U.N. News&quot; V1.0" />
                                </toolkit:MenuItem.Header>
                            </toolkit:MenuItem>
                        </toolkit:ContextMenu>
                    </toolkit:ContextMenuService.ContextMenu>
            </TextBlock>
            <TextBlock x:Name="PageTitle" Text="{Binding Title}" TextWrapping="Wrap"  Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" Foreground="Black" FontSize="{StaticResource PhoneFontSizeLarge}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox HorizontalAlignment="Left" VerticalAlignment="Top" ItemTemplate="{StaticResource ArticleItemDataTemplate}" SelectionChanged="ArticleList_SelectionChanged" ItemsSource="{Binding ArticleViewModels}"/>
        </Grid>
        <TextBlock Visibility="Visible" Opacity="1" x:Name="loadingText" Height="27" Margin="0,0,0,5" TextWrapping="Wrap" Text="Loading..." VerticalAlignment="Bottom" Foreground="Black" FontSize="{StaticResource PhoneFontSizeSmall}" HorizontalAlignment="Center" />
        <ProgressBar x:Name="loadingProgressBar" Height="8" Margin="-12,0" Style="{StaticResource PerformanceProgressBar}" VerticalAlignment="Bottom" IsIndeterminate="True"/>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</Framework:BasePage>
